package com.kcwl.carrier.infrastructure.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author 刘旭超
 * @date 2022年07月11日 15:01
 * @Description 校验工具类
 */
public class VerifyUtil {

    /**
     * 证件号
     */
    public static final String ID_CARD_REGEX = "^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$";
    private static final Pattern ID_CARD_PATTERN = Pattern.compile(ID_CARD_REGEX);

    public static boolean idCardVerify(String idCard) {
        Matcher matcher = ID_CARD_PATTERN.matcher(idCard);
        return matcher.matches();
    }

    /**
     * 手机号
     */
    public static final String MOBILE_REGEX = "^1\\d{10}$";
    private static final Pattern MOBILE_PATTERN = Pattern.compile(MOBILE_REGEX);

    public static boolean mobileVerify(String mobile) {
        Matcher matcher = MOBILE_PATTERN.matcher(mobile);
        return matcher.matches();
    }

    /**
     * 匹配字母数字
     */
    public static final String LETTER_NUMBER_REGEX = "^[A-Za-z0-9]{16}$";
}
